package FCRendering;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.JPanel;

import Function.FCSound;

@Deprecated
public class FCRGetReadyOnePlayer extends JPanel {
	private FCSound sound;
	private Image getready = Toolkit.getDefaultToolkit().getImage("./getReady/getready.png");
	private Image newsave = Toolkit.getDefaultToolkit().getImage("./getReady/newsave.png");
	private int enterBu = 0;
	private int clickBu = 0; 
	private float bili;

	public FCRGetReadyOnePlayer(FCSound sound) {
		this.sound = sound;
		addMouseMotionListener(new MouseMotionListener() {
			@Override
			public void mouseMoved(MouseEvent e) {
				int x = e.getX(), y = e.getY();
				if (clickBu == 0) {
					if (y > 936 && y < 976) {
						if (x > 926 * bili && x < 1051 * bili)
							enterBu = 1;// TODO
						if (x > 1080 * bili && x < 1205 * bili)
							enterBu = 2;// TODO
						if (x > 1234 * bili && x < 1359 * bili)
							enterBu = 3;// TODO
					}
				}
			}

			@Override
			public void mouseDragged(MouseEvent e) {
			}
		});
		addMouseListener(new MouseListener() {
			@Override
			public void mouseReleased(MouseEvent e) {
			}

			@Override
			public void mousePressed(MouseEvent e) {
			}

			@Override
			public void mouseExited(MouseEvent e) {
			}

			@Override
			public void mouseEntered(MouseEvent e) {
			}

			@Override
			public void mouseClicked(MouseEvent e) {
				int x = e.getX(), y = e.getY();
				if (clickBu == 0) {
					if (y > 936 && y < 976) {
						if (x > 926 * bili && x < 1051 * bili)
							clickBu = 1;// TODO
						if (x > 1080 * bili && x < 1205 * bili)
							clickBu = 2;// TODO
						if (x > 1234 * bili && x < 1359 * bili)
							clickBu = 3;// TODO
					}
				}
			}
		});
		setVisible(true);
		Timer ti = new Timer();
		ti.schedule(new updataUI(), new Date(), 50);
	}

	@Override
	protected void paintComponent(Graphics g) {
		g.drawImage(getready, 0, 0, this);
		// TODO
		g.setColor(new Color(163, 163, 163));
		if (enterBu >= 1 && enterBu <= 3)
			g.fillRect(752 + 154 * enterBu, 940, 14, 32);
	}

	@Override
	public void setBounds(int x, int y, int width, int height) {
		super.setBounds(x, y, width, height);
		bili = getWidth() / 1920;
		bili = (bili > getHeight() / 1080) ? getHeight() / 1080 : bili;
	}

	private class updataUI extends TimerTask {

		@Override
		public void run() {
			repaint();
		}

	}
}
